package itcast.web.servlet;

import itcast.domain.Buildmanager;
import itcast.domain.PageBean;
import itcast.service.BuildmanagerService;
import itcast.service.impl.BuildmanagerServiceimpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/findBuildmanagerByPageServlet")
public class FindBuildmanagerByPageServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //1.获取参数
        String currentPage=request.getParameter("currentPage");//当前页码
       String rows= request.getParameter("rows");//每页显示的条数
        //2.调用Service查询
        BuildmanagerService service =new BuildmanagerServiceimpl();
       PageBean<Buildmanager> pb=service.findBuildmanagerByPage(currentPage,rows);
        System.out.println(pb);
       //3.将PageBean存入request
        request.setAttribute("pb",pb);
        //4.转发到Build-management.jsp
        request.getRequestDispatcher("systemadmin/Building-management.jsp").forward(request,response);

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        this.doPost(request,response);
    }
}
